package com.whut.controller;

import com.whut.model.Manageinfo;
import com.whut.model.Orderinfo;
import com.whut.model.Userinfo;
import com.whut.service.ManageService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/manage")
public class ManageController {
    @Resource
    private ManageService manageService;

    /**
     * @auther wenyihan
     * 通过id查找员工所有的状态
     * @date 17:34 2019/10/29
     * @param （id, userName）
     * @return java.lang.Object
    */
    @ResponseBody
    @PostMapping("/getRegistInfoById")
    public Object getRegistInfoById(int id, String userName){
        return manageService.getRegistInfoById(id, userName);
    }


    @ResponseBody
    @PostMapping("/getUserById")
    public Userinfo getUserById(int mKey){
        return manageService.getUserById(mKey);
    }

    @ResponseBody
    @PostMapping("/getAllUserInfoByMark")
    public List<Object> getAllUserInfoByMark(Integer mark){
        return manageService.getAllUserInfoByMark(mark);
    }

    @ResponseBody
    @PostMapping("/getManageInfo")
    public Manageinfo getManageInfo(Integer id, Integer registTime){

        return manageService.getManageInfo(id,registTime);
    }

    @ResponseBody
    @PostMapping("/updateManageInfo")
    public String updateManageInfo(Manageinfo manageinfo){

        return manageService.updateManageInfo(manageinfo);
    }
    @ResponseBody
    @PostMapping("/getOrderById")
    public Orderinfo getOrderById(Integer id){
        return manageService.getOrderById(id);
    }

    @ResponseBody
    @PostMapping("/deleteUserById")
    public String deleteUserById(Integer id){
        return manageService.deleteUserById(id);
    }

    @ResponseBody
    @PostMapping("/updateRoomStatusByRoomId")
    public String updateRoomStatusByRoomId(Integer roomId,Integer roomStatus){
        return manageService.updateRoomStatusByRoomId(roomId,roomStatus);
    }

    @ResponseBody
    @PostMapping("/updateUserInfo")
    public String updateUserInfo(Userinfo userinfo){
        return manageService.updateUserInfo(userinfo);
    }

    @ResponseBody
    @PostMapping("/updateOrder")
    public String updateOrder(Orderinfo orderinfo){
        return manageService.updateOrder(orderinfo);
    }

    @ResponseBody
    @PostMapping("/updateReason")
    public String updateReason(Integer id,String registTime,String reason){
        return manageService.updateReason(id,registTime,reason);
    }

    @ResponseBody
    @PostMapping("/deleteManageInfo")
    public String deleteManageInfo(Integer id,String registTime){

        return manageService.deleteManageInfo(id,registTime);
    }

    @ResponseBody
    @PostMapping("/addUserInfo")
    public String addUserInfo(Userinfo userinfo){

        return manageService.addUserInfo(userinfo);
    }

    @ResponseBody
    @PostMapping("/getLeaveTimes")
    public Integer getLeaveTimes(Integer id,Integer registTime){

        return manageService.getLeaveTimes(id,registTime);
    }

    @ResponseBody
    @PostMapping("/getRegistTimes")
    public Integer getRegistTimes(Integer id,Integer registTime){

        return manageService.getRegistTimes(id,registTime);
    }

    @ResponseBody
    @PostMapping("/getAllPostInfo")
    public List<Object> getAllPostInfo(){

        return manageService.getAllPostInfo();
    }

    @ResponseBody
    @PostMapping("/getAllUserInfo")
    public Object getAllUserInfo(){

        return manageService.getAllUserInfo();
    }

    /**
     * @auther wenyihan
     * 获取当天所有的请假信息
     * @date 14:30 2019/11/1
     * @return java.lang.Object
    */
    @ResponseBody
    @PostMapping("/getAllLeaveInfo")
    public Object getAllLeaveInfo(){return manageService.getAllLeaveInfo();}

    /**
     * @auther wenyihan
     * 获取某天的所有请假信息
     * @date 15:09 2019/11/1
     * @param （date）
     * @return java.lang.Object
    */
    @ResponseBody
    @PostMapping("/getLeaveByDate")
    public Object getLeaveByDate(String date){return manageService.getAllLeaveInfoByDate(date);}

    /**
     * @auther wenyihan
     * 管理员不同意请假信息
     * @date 18:25 2019/11/1
     * @param （id, date）
     * @return java.lang.Object
    */
    @ResponseBody
    @PostMapping("/disagree")
    public Object disagree (int id, String date){return manageService.disagree(id, date);}

    /**
     * @auther wenyihan
     * 筛选某天某个学生的打卡信息
     * @date 20:57 2019/11/1
     * @param （id, startTime, endTime）
     * @return java.lang.Object
    */
    @ResponseBody
    @PostMapping("/getRegistInfoByTime")
    public  Object getRegistInfoByTime (int id, String startTime, String endTime, String leaveTime){
        return manageService.getRegistInfoByTime(id, startTime, endTime, leaveTime);
    }

    @ResponseBody
    @PostMapping("/updatePostTypeInfo")
    public  String updatePostTypeInfo (String postType, Integer baseSalary, Integer bonus){
        return manageService.updatePostTypeInfo(postType,baseSalary,bonus);
    }

    @ResponseBody
    @PostMapping("/getSalaryByPostType")
    public  Object getSalaryByPostType (String postType){
        return manageService.getSalaryByPostType(postType);
    }

    @ResponseBody
    @PostMapping("/updatePayById")
    public  String updatePayById (Integer id,Integer pay){
        return manageService.updatePayById(id,pay);
    }

    @ResponseBody
    @PostMapping("/settlePay")
    public  String settlePay (Integer id){
        return manageService.settlePay(id);
    }
}
